<template>
    <el-button type="primary" @click="onSubmit">确认修改</el-button>
  <div>
    <el-tree
      ref="treeRef"
      :data="data.list"
      show-checkbox
      :check-strictly = 'true'
      node-key="roleId"
      :default-checked-keys="data.authorityIds"
      :props="{
        children: 'roleList',
        label: 'name',
      }"
    />
  </div>
</template>

<script setup lang="ts">
import { reactive,ref } from "@vue/reactivity";
import { useRoute } from "vue-router";
import { QueryInt, InitData } from "../../../type/authority";
import { getAuthority } from "../../../http/api";
import { onMounted } from "@vue/runtime-core";
import { ElTree } from 'element-plus'
const route = useRoute();
const treeRef = ref<InstanceType<typeof ElTree>>()
//获取路由跳转传递进来的信息
const val:any = localStorage.getItem('query')
if(route.query.id) {
    var query: any = route.query
    console.log(query,111);
}else{
    var query: any = JSON.parse(val);
    console.log(query,222);
    
}
const data = reactive(new InitData(query.id, query.authority));
onMounted(() => {
    localStorage.setItem('query',JSON.stringify(query))
  getAuthority().then((res) => {
    data.list = res.data;
  });
});
const onSubmit = () => {
    console.log(treeRef.value?.getCheckedKeys()); 
    alert("http提交")
}
</script>

<style scoped>
</style>